/*
 * 作者:熊猫
 * 日期:2017 - 3 - 16 5 - 10 - 43
 *
 */

package net.lainiao.morethread.Chapter7.demo3;

import java.util.concurrent.ThreadFactory;

/**
 * Created by Administrator on 2017/3/16.
 */
public class MyThreadFactory implements ThreadFactory {
    private int counter;
    private String prifix;

    public MyThreadFactory(String prifix) {
        this.prifix = prifix;
        counter = 1;
    }

    @Override
    public Thread newThread(Runnable r) {
        MyThread myThread = new MyThread(r, prifix + "-" + counter);
        counter++;
        System.out.println("Create MyThread");
        return myThread;
    }

}
